package com.sisgh.jefdv1.cmd.command.has.arg.argument.function.format.impl;

import com.sisgh.jefdv1.cmd.command.has.arg.argument.function.format.MarkerChecker;
import com.sisgh.jefdv1.util.StringUtils;

public record ArgMarker(String longMarker, String shortMarker) implements MarkerChecker {

    @Override
    public boolean check(String arg) {
        if (StringUtils.isNullOrEmpty(arg)){
            return false;
        }

        if (arg.length() > longMarker.length()){
            String lm = arg.substring(0, longMarker.length());

            return lm.equals(longMarker);
        } else if (arg.length() > shortMarker.length()){
            String sm = arg.substring(0, shortMarker.length());

            return sm.equals(shortMarker);
        }

        return false;
    }

}
